/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import java.awt.Color;
import java.awt.Component;
import java.util.GregorianCalendar;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author Ira
 */
public class ReserveCellRenderer extends DefaultTableCellRenderer {
	
	private static GregorianCalendar year1 = new GregorianCalendar(1, 0, 1);
	
	@Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
		
		GregorianCalendar cal = (GregorianCalendar)value;
		if(cal == null) {
			this.setText("disponible");
			this.setBackground(Color.decode(""));
			return this;
		}
		else if(ReserveCellRenderer.year1.equals(cal)) {
			this.setText("liste d'attente");
		}
		else {
			this.setText(cal.get(GregorianCalendar.DATE) + "/" + (cal.get(GregorianCalendar.MONTH)+1) + "/" + Integer.toString(cal.get(GregorianCalendar.YEAR)));
		}
        return this;
    }
}
